package com.hust.bridgecheck.repository;

import com.hust.bridgecheck.entity.EarlyWarning;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface  EarlyWarningRepository extends JpaRepository<EarlyWarning,Integer> {
 @Query(nativeQuery = true, value = "select * from early_warning where bridgeid = ?1 and is_remove = ?2")
    List<EarlyWarning> getEarlyWarningByBridgeID(Integer bridgeid, Integer is_remove);

    @Transactional
    @Modifying(clearAutomatically = true)
 @Query(nativeQuery = true, value = "update early_warning set is_remove = 1 where id = ?1")
    int deleteEarlyWarningByID(Integer earlywarningid);

  @Query(nativeQuery = true,value = "select * from early_warning where paraid = ?1 and is_remove = ?2")
    EarlyWarning getEarlyWarningByParaID(String paraID, Integer is_remove);
}
